<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8">
        <title>更新页面</title>
        <link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
        <link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
        <link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
        <style>
            table thead tr{
                background-color: #f2f2f2;
            }
            table tbody .layui-table-cell{
                height: 60px;
                position: relative;
                box-sizing: border-box;
            }
        </style>
    </head>
    <body>

    <!-- 数据表格 -->
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="data-table2" lay-filter="data-table2"></table>
        </div>
    </div>

        <script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
        <script src="/app/admin/component/pear/pear.js"></script>
        <script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
        <script src="/app/admin/admin/js/permission.js"></script>
        <script src="/app/admin/admin/js/functions.js"></script>
        <script src="/app/admin/admin/js/md5.js"></script>
        
        <script>
            // 相关接口
            const PRIMARY_KEY = "id";
            const PRIMARY_KEY_VALUE = layui.url().search[PRIMARY_KEY];
            const TYPE_VALUE = layui.url().search['type'];
            const SELECT_API = "/app/admin/material/index/select" + location.search;

            // 获取数据库记录
            layui.use(["form", "util", "popup","table","common"], function () {
                $ = layui.$;
                let table = layui.table;
                $.ajax({
                    url: SELECT_API,
                    dataType: "json",
                    async:true,
                    headers: get_header({"id":PRIMARY_KEY_VALUE,"type":TYPE_VALUE}),
                    success: function (res) {
                        let upload_videos = [];
                        if(TYPE_VALUE==1){
                            upload_videos = res.data[0]['heigh_video_data'];
                        }else if(TYPE_VALUE==2){
                            upload_videos = res.data[0]['normal_video_data'];
                        }

                        //表格渲染
                        table.render({
                            elem: '#data-table2'
                            //, toolbar: '#toolbarAttr'
                            , title: '列表'
                            , text: {
                                none: '暂无相关数据'
                            }
                            //, width:950
                            , defaultToolbar: []
                            , cols: [[ //表头
                                {
                                    title: "序号",align: "center", field: "id",sort:true,
                                },
                                {
                                    title: '视频',align: "center", field: 'video', templet:function (d) {
                                        if(d.video){
                                            return '<div data-video="'+d.video+'" onclick="open_video(this)">' +
                                                '<video width="60" height="60">'+
                                                '<source src="'+d.video+'" type="video/mp4">'+
                                                '<object data="'+d.video+'" width="500" height="800">'+
                                                '</object> '+
                                                '</video>' +
                                                '</div>';
                                        }else{
                                            return ' ';
                                        }
                                    }
                                },
                                {
                                    title: "时长(秒)",align: "center", field: "tts",sort:true,
                                },
                                {
                                    title: "分辨率",align: "center", field: "video_scale",sort:true,
                                },
                                {
                                    title: "宽度",align: "center", field: "width",sort:true,
                                },
                                {
                                    title: "高度",align: "center", field: "height",sort:true,
                                },
                                {
                                    title: "名称",align: "center", field: "name",sort:true,
                                }
                            ]]
                            , data: upload_videos
                            , page: true
                        });

                        // ajax返回失败
                        if (res.code) {
                            layui.popup.failure(res.msg);
                        }

                    }
                });
            });
        </script>

    </body>

</html>
